#include "RasterLayerProperty.h"
#include "RasterLayer.h"

RasterLayerProperty::RasterLayerProperty(RasterLayer* rasterLayer, QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	initializeGui(rasterLayer);
}

RasterLayerProperty::~RasterLayerProperty()
{

}

void RasterLayerProperty::initializeGui(RasterLayer* rasterLayer)
{
	int bandCount = rasterLayer->getBandCount();
	ui.txtBandRange->setText(QString::number(1) + "-" + QString::number(bandCount));
	std::vector<QComboBox*> comboxs;
	comboxs.push_back(ui.cmbR);
	comboxs.push_back(ui.cmbG);
	comboxs.push_back(ui.cmbB);

	for (size_t i = 0; i < comboxs.size(); ++i)
	{
		for (int j = 1; j <= bandCount; ++j)
		{
			comboxs[i]->addItem(QString::number(j));
		}
	}

	ui.cmbR->setCurrentIndex(rasterLayer->getBandChoiceR() - 1);
	ui.cmbG->setCurrentIndex(rasterLayer->getBandChoiceG() - 1);
	ui.cmbB->setCurrentIndex(rasterLayer->getBandChoiceB() - 1);
}

int RasterLayerProperty::getBandChoiceR() const
{
	return ui.cmbR->currentText().toInt();
}

int RasterLayerProperty::getBandChoiceG() const
{
	return ui.cmbG->currentText().toInt();
}

int RasterLayerProperty::getBandChoiceB() const
{
	return ui.cmbB->currentText().toInt();
}
